package com.ruoyi.cbs.project.services;

import com.ruoyi.cbs.project.domain.Project;
import com.ruoyi.cbs.project.domain.vo.ProjectSelectVo;
import com.ruoyi.cbs.project.service.IProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ProjectServices {
    @Autowired
    private IProjectService projectService;


    /**
     * 查询承包商列表
     * @return
     */
    public List<ProjectSelectVo> selectProjectList(String projectName, String searchStatus) {
        Project searchEntity = new Project();
        searchEntity.setProjectName(projectName);
        searchEntity.setSearchStatus(searchStatus);
        List<Project> projectList = projectService.selectList(searchEntity);

        List<ProjectSelectVo> projectSelectVoList = new ArrayList<>();
        for (Project project : projectList) {
            ProjectSelectVo projectSelectVo = new ProjectSelectVo();
            BeanUtils.copyProperties(project, projectSelectVo);
            projectSelectVo.setProjectId(project.getId());
            projectSelectVoList.add(projectSelectVo);
        }

        return projectSelectVoList;
    }


}
